#include <stdlib.h>
#include <stdio.h>
#include <SDL.h>
#include "barre.h"
#include "carrer.h"
void modejoueur(SDL_Rect* posy,int *deplacement, SDL_Surface *ecran, SDL_Surface *carrer, int* boucle)
 {
    int er = 0, i = 0;
    static int nb[8] = {0, 0, 0, 0, 0, 0, 0, 0};
    SDL_Rect pos, p;
    p.x = 0;
    p.y = 0;
    pos = barre(ecran, boucle);
    er = rebond(*posy, deplacement, pos, nb);
    bouger(ecran, carrer, posy, *deplacement);
    bloc(ecran, nb);
    SDL_Delay(1);
    SDL_Flip(ecran);

    if(er == 2)
    {
        SDL_Surface *image = NULL;
        image = SDL_LoadBMP("game-over.bmp");
        SDL_BlitSurface(image, NULL, ecran, &p);
        SDL_Flip(ecran);
        SDL_Delay(1250);
        *boucle = 0;
    }
    if(er == 8)
    {
        SDL_Surface *imageu = NULL;
        imageu = SDL_LoadBMP("winner-win.bmp");
        SDL_BlitSurface(imageu, NULL, ecran, &p);
        SDL_Flip(ecran);
        SDL_Delay(2000);
        *boucle = 0;
    }
 }
